import req from "@/utils/request";
const baseURL = process.env.VUE_APP_BASE_URL;
export function createDeviceTypes(data) {
  return req({
    method: "post",
    url: baseURL + "/superlink/api/devicetypes/create",
    data
  });
}
export function updateDeviceTypes(data, deviceTypeToken) {
  return req({
    method: "put",
    url: baseURL + "/superlink/api/devicetypes/update/" + deviceTypeToken,
    data
  });
}
export function addPoints(data, deviceTypeToken) {
  return req({
    method: "post",
    url:
      baseURL +
      "/superlink/api/devicetypes/create/" +
      deviceTypeToken +
      "/attributes",
    data
  });
}
export function editPointsApi(data, deviceTypeToken, oldToken) {
  return req({
    method: "put",
    url:
      baseURL +
      "/superlink/api/devicetypes/update/" +
      deviceTypeToken +
      "/attribute/" +
      oldToken,
    data
  });
}
export function addCommand(data, deviceTypeToken, oldToken) {
  return req({
    method: "post",
    url:
      baseURL +
      "/superlink/api/devicetypes/create/" +
      deviceTypeToken +
      "/commands",
    data
  });
}
export function editCommand(data, deviceTypeToken, oldToken) {
  return req({
    method: "put",
    url:
      baseURL +
      "/superlink/api/devicetypes/update/" +
      deviceTypeToken +
      "/commands/" +
      oldToken,
    data
  });
}
export function addDeviceState(data, deviceTypeToken, oldToken) {
  return req({
    method: "post",
    url:
      baseURL +
      "/superlink/api/devicetypes/create/" +
      deviceTypeToken +
      "/statuses",
    data
  });
}
export function editDeviceState(data, deviceTypeToken, oldToken) {
  return req({
    method: "put",
    url:
      baseURL +
      "/superlink/api/devicetypes/update/" +
      deviceTypeToken +
      "/statuses/" +
      oldToken,
    data
  });
}
export function getDeviceTypes(data) {
  return req({
    method: "get",
    url: baseURL + "/superlink/api/devicetypes",
    params: data
  });
}
export function getDeviceTypesV2(data) {
  return req({
    method: "get",
    url: baseURL + "/superlink/api/devicetypes/v2/devicetypes",
    params: data
  });
}

export function getDetailsTab(url, data) {
  return req({
    method: "get",
    url: baseURL + url,
    params: data
  });
}
export function deleteDeviceType(deviceTypeToken) {
  return req({
    method: "delete",
    url: baseURL + "/superlink/api/devicetypes/delete/" + deviceTypeToken
  });
}
export function getDeviceDetails(params, deviceTypeToken) {
  return req({
    method: "get",
    url: baseURL + "/superlink/api/devicetypes/" + deviceTypeToken,
    params
  });
}
export function getQrcodeData(params, deviceTypeToken) {
  return req({
    method: "get",
    url:
      baseURL +
      "/superlink/api/devicetypes/" +
      deviceTypeToken +
      "/label/qrcode",
    responseType: params.responseType
  });
}
export function getDeviceTypeAttributes(params, deviceTypeToken) {
  return req({
    method: "get",
    url:
      baseURL + "/superlink/api/devicetypes/" + deviceTypeToken + "/attributes",
    params
  });
}
export function getDeviceAttributes(params, deviceToken) {
  return req({
    method: "get",
    url: baseURL + "/superlink/api/devices/" + deviceToken + "/attributes",
    params
  });
}
export function postFormulaInv(data, deviceToken) {
  return req({
    method: "post",
    url: baseURL + `/superlink/api/devices/${deviceToken}/formula/invocations`,
    data
  });
}
